import re
from django.http import JsonResponse
from django.shortcuts import render
from django.views import View
from apps.users.models import User
# Create your views here.

class UsernameCountView(View):
    def get(self,request,username):
        # rules = '[a-zA-Z0-9]{5,20}'
        # if not re.match(rules,username):
        #     return JsonResponse({'code':0,'errmsg':'用户名格式错误'})
        count = User.objects.filter(username=username).count()
        return JsonResponse({'code':1,'count':count,'errmsg':'ok'})
